from pyecharts import options as opts
from pyecharts.charts import Bar

# 数据
values = [40, 5, 5]
categories = ["入职", "转入", "转出"]
total = sum(values)

# 创建条形图
bar = (
    Bar(init_opts=opts.InitOpts(bg_color="#1D244A"))
    .add_xaxis(categories)
    .add_yaxis("", values, color="#7AD5FE", category_gap="80%")
    .set_global_opts(
        title_opts=opts.TitleOpts(
            title=f"总人数: {total}\n入转调",
            pos_left="center",
            title_textstyle_opts=opts.TextStyleOpts(color="white", font_size=16)
        ),
        xaxis_opts=opts.AxisOpts(
            axislabel_opts=opts.LabelOpts(color="white"),
            axisline_opts=opts.AxisLineOpts(is_show=True),
            axistick_opts=opts.AxisTickOpts(is_show=False),
            splitline_opts=opts.SplitLineOpts(is_show=False)
        ),
        yaxis_opts=opts.AxisOpts(
            axislabel_opts=opts.LabelOpts(is_show=False),
            axisline_opts=opts.AxisLineOpts(is_show=False),
            axistick_opts=opts.AxisTickOpts(is_show=False),
            splitline_opts=opts.SplitLineOpts(is_show=False)
        ),
        legend_opts=opts.LegendOpts(is_show=False),
    )
    .set_series_opts(
        label_opts=opts.LabelOpts(position="top", color="white", formatter="{c}")
    )
)

# 渲染图表
bar.render("bar_chart.html")
